package com.example.test.chapter7.custom_listview_3_row;

import java.util.ArrayList;
import java.util.HashMap;

import com.example.test.R;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;

public class CListView2 extends ListActivity {
	static final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.clistview1);
		SimpleAdapter adapter = new SimpleAdapter(this, list,
				R.layout.crowview1,
				new String[] { "rank", "model", "company" }, new int[] {
						R.id.text1_list_vew_3_row, R.id.text2_list_vew_3_row,
						R.id.text3_list_vew_3_row });
		populateList();
		setListAdapter(adapter);
	}

	private void populateList() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("rank", "1");
		map.put("model", "Samsung Galaxy Nexus");
		map.put("company", "Samsung");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "2");
		map.put("model", "Samsung Epic Touch 4G");
		map.put("company", "Samsung");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "3");
		map.put("model", "HTC Evo 3D");
		map.put("company", "HTC");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "4");
		map.put("model", "T-Mobile MyTouch 4G Slide");
		map.put("company", "HTC");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "5");
		map.put("model", "Samsung Galaxy S II");
		map.put("company", "Samsung");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "6");
		map.put("model", "Apple iPhone 4S 16GB");
		map.put("company", "Apple");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "7");
		map.put("model", "Motorola Droid Razr");
		map.put("company", "Motorola");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "8");
		map.put("model", "Motorola Droid Bionic");
		map.put("company", "Motorola");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "9");
		map.put("model", "Samsung Focus S");
		map.put("company", "Samsung ");
		list.add(map);
		map = new HashMap<String, String>();
		map.put("rank", "10");
		map.put("model", "Samsung Focus Flash");
		map.put("company", "Samsung");
		list.add(map);
	}
}
